package com.zz.framework.core.ext.keybord

import android.view.View

/**
 * Copyright © 2019 zanezhao All rights reserved.
 * Created by zanezhao on 2019/12/1 9:58 PM.
 * @author: zanezhao 1820022519@qq.com
 * @version: V1.0
 */
internal class ShowChangedController(private val onShowChanged: OnKeyboardShowChanged) {
    private var shown: Boolean? = null
    private var inAppHeight: Int = 0

    fun update(anyView: View) {
        val shown = anyView.isKeyboardShown
        val inAppHeight = anyView.keyboardHeight

        if (this.shown == null || this.shown != shown || this.inAppHeight != inAppHeight) {
            this.shown = shown
            this.inAppHeight = inAppHeight
            onShowChanged(shown, inAppHeight)
        }
    }
}